/**
 * @author Vladimir Kondratyev
 * @author Michael Gerasimov
 */
package com.intellij.tfsSupport;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.DefaultJDOMExternalizer;
import com.intellij.openapi.util.InvalidDataException;
import com.intellij.openapi.util.JDOMExternalizable;
import com.intellij.openapi.util.WriteExternalException;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;

import java.util.ArrayList;
import java.util.List;

/**
 * Describes set of operation's options. Consider this class just as the
 * structure.
 */
public class AddOptions implements JDOMExternalizable
{
  @NonNls private static final String ADD_COMMAND = "Add";

      @NonNls private static final String RECURSIVE_OPTION = "/recursive";


    @NonNls public static final String TAG = "AddOptions";

  public boolean STORE_ONLY_LATEST_VERSION;
  public boolean CHECK_OUT_IMMEDIATELY;

  private VssConfiguration myConfig;

  public AddOptions( VssConfiguration config )
  {
    myConfig = config;
  }

  /**
   * Creates option set for passed file.
   */
  public List<String> getOptions( VirtualFile virtualFile , Project project)
  {
    ArrayList<String> options = new ArrayList<String>();
    options.add( ADD_COMMAND );
    options.add(  VssUtil.getVssPath( virtualFile, project));

    //-- Comments --
    //  We use unified Checkin dialog for all operations - add new, update
    //  changed etc. Thus for "ADD" operation we inherit the comment usually
    //  stored in the "CHECKIN" operation environment.
      if(virtualFile.isDirectory())
      {
          options.add(RECURSIVE_OPTION);
      }
    return options;
  }

  public void readExternal(Element element) throws InvalidDataException {
    DefaultJDOMExternalizer.readExternal(this, element);
  }

  public void writeExternal(Element element) throws WriteExternalException {
    DefaultJDOMExternalizer.writeExternal(this, element);
  }
}
